<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<?php echo $commander->getListCommandsPanel('s', ''); ?>
<fieldset class="edit_form">
	<?php if ($shop->getGlobalSetting('use_stock_units')): ?>
    <label for="name"><?php echo ucfirst($txt->getWord('stock')).' '.ucfirst($txt->getWord('unit')); ?></label>
    <?php 
        if($error['stock_unit'])
        { echo '<span class="error">'.$error['stock_unit'].'</span>'; }
        if($error['stock_unit'])
        { echo '<span class="info">'.$info['stock_unit'].'</span>'; }
    ?>
    <input name="stock_unit" class="large" type="text" value="<?php echo $shop->CurrentProduct->StockUnit; ?>" maxlength="20">
    <?php endif; ?>
    <?php if ($shop->getGlobalSetting('use_dim_shipping_calculation')): ?>
    <label for="name"><?php echo ucfirst($txt->getWord('weight')).' '.ucfirst($txt->getWord('unit')); ?></label>
    <?php 
        if($error['weight_unit'])
        { echo '<span class="error">'.$error['weight_unit'].'</span>'; }
        if($error['weight_unit'])
        { echo '<span class="info">'.$info['weight_unit'].'</span>'; }
    ?>
    <input name="weight_unit" class="large" type="text" value="<?php echo $shop->CurrentProduct->WeightUnit; ?>" maxlength="20">
    <label for="name"><?php echo ucfirst($txt->getWord('dimunit')); ?></label>
    <?php 
        if($error['dim_unit'])
        { echo '<span class="error">'.$error['dim_unit'].'</span>'; }
        if($error['dim_unit'])
        { echo '<span class="info">'.$info['dim_unit'].'</span>'; }
    ?>
    <input name="dim_unit" class="large" type="text" value="<?php echo $shop->CurrentProduct->DimUnit; ?>" maxlength="20">
    <br /><hr />
    <?php endif; ?>
    <?php if ($shop->getGlobalSetting('attributes')): ?>
    <label for="name"><?php echo ucfirst($txt->getWord('attributes')); ?></label>
    <input type="hidden" id="add_attribute" name="add_attribute" value="0" />
    <input type="hidden" id="rem_attribute" name="rem_attribute" value="0" />
    <select id="select_attribute" name="select_attribute" class="medium">
        <option value="0"><?php echo ucfirst($txt->getWord('select').' '.$txt->getWord('attribute')); ?></option>
        <?php
        if($shop->getProductAttributes())
        {
            $found = 0;
            foreach($shop->getProductAttributes() as $att)
            { 
                if($shop->CurrentProduct->getAttributes())
                {
                    if(isset($shop->CurrentProduct->Attributes[$att->getId()]))
                    { $found = 1; }
                }
                if($found == 0)
                { echo '<option value="'.$att->getId().'">'.$att->getTitle().' ('.$att->getTitleImport().')</option>'; }
                $found = 0;
            }
        }
        ?>
    </select><img class="icon command" src="<?php echo SYSICONS_URL; ?>add_16.gif" onclick="edit_form.add_attribute.value=document.getElementById('select_attribute').value; if(document.getElementById('add_attribute').value > 0) { edit_form.submit(); }"  />
    <?php if($shop->CurrentProduct->getAttributes()): ?> 
    <table>
        <?php 
        foreach($shop->CurrentProduct->getAttributes() as $att)
        { 	
            echo '<tr>'; 
                echo '<td>'; 	
                echo '<img class="icon command" src="'.SYSICONS_URL.'remove_16.gif" onclick="edit_form.rem_attribute.value='.$att['id'].'; if(document.getElementById(\'rem_attribute\').value > 0) { edit_form.submit(); }"  />&nbsp;&nbsp;';
                echo $att['title'];
                echo '</td>';
                echo '<td>';
                if($att['effect'] == 0)
                {
                    ?>
                    <input type="hidden" name="att_product[]" value="<?php echo $att['id']; ?>" />
                    <input type="hidden" name="att_predef[]" value="<?php echo $att['predefined']; ?>" />
                    <input type="hidden" name="att_valtype[]" value="<?php echo $att['val_type']; ?>" />
                    <?php
                    if($att['predefined'] == 1)
                    {
                        $att['values'] = $ShopAtt->getShopAttributeValues($att['id']);
                        ?>
                        :&nbsp;<select name="att_val_id[]" class="medium">
                            <option value="0">Select Attribute Value</option>
                            <?php
                            if($att['values']) 
                            {
                                foreach($att['values'] as $value)
                                { echo '<option value="'.$value['id'].'" '.getIsSelectedHTML($value['id'], $att['value']['value_id']).'>'.$value['value'].'</option>'; }
                            }
                            ?>
                        </select>
                        <?php
                        echo '<a href="?con='.$_GET['con'].'&attribute='.$att['id'].'"><img class="icon command" src="'.SYSICONS_URL.'edit_16.gif" /></a>'; 
                    }
                    else
                    {
                        ?>
                        :&nbsp;<input type="text" class="medium" maxlength="99" name="att_value[]" value="<?php echo $att['value']['value']; ?>" />
                        <?php 
                    }
                }
                echo '</td>';
            echo '</tr>'; 
        }
        ?>
    </table>
    <?php endif; ?>
    <?php endif; ?>
</fieldset>